home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#09 (Jun 86)
/
Forth source code
/
CRT saver.VBL
< prev
Wrap
Text File
|
1986-04-08
|
7KB
|
292 lines
( CRT saver task for installation into VBLTask queue, 4.4.86 JL )
only forth definitions
also assembler also mac
hex
29A constant JGNEFilter
824 constant screenbase
904 constant currentA5
9EE constant grayRgn
16A constant Ticks
74 constant screenbits
10 constant portrect
FFFFFFFF constant minusone
.TRAP _drawmenubar $A937
.TRAP _frontwindow $A924
.TRAP _paintbehind $A90D
.TRAP _newptr,sys $A51E
.TRAP _showcursor $A853
CODE save.regs
MOVE.W SR,-(A7)
MOVEM.L A1-A6/D0-D7,-(A7)
RTS
END-CODE MACH
CODE restore.regs
MOVEM.L (A7)+,A1-A6/D0-D7
MOVE.W (A7)+,SR
RTS
END-CODE MACH
CODE getA1
MOVE.L A1,-(A6)
RTS
END-CODE MACH
decimal
header START
( *** we need two local stacks after the relocation *** )
header GNE.stack 100 allot
CODE setup.GNE.stack
LEA -8(PC),A6 ( GNE stack grows downward from here )
RTS
END-CODE
header VBL.stack 100 allot
CODE setup.VBL.stack
LEA -8(PC),A6 ( VBL stack grows downward from here )
RTS
END-CODE
( *** define port structure + some global variables *** )
header screenport
2 allot ( device )
14 allot ( bitmap )
8 allot ( portrect )
84 allot ( remaining bytes )
header myevents
2 allot ( code )
4 allot ( message )
4 allot ( when )
4 allot ( where )
2 allot ( modifiers )
( *** VBL queue element to be installed *** )
header VBLqelem
4 allot ( qLink )
2 allot ( qType )
4 allot ( vblAddr )
2 allot ( vblCount )
2 allot ( vblPhase )
1 constant vType
4 constant qType
6 constant vblAddr
10 constant vblCount
12 constant vblPhase
( *** GetNextEvent filter proc definitions *** )
header SavedJGNEFilter 4 allot
header dark 4 allot
header last.action 4 allot
header max.ticks 4 allot
3600 ' max.ticks ! ( 1 min in ticks )
: GNEIntfc
save.regs
setup.GNE.stack
getA1 w@ ( event received? )
IF ticks @ ['] last.action !
['] dark @
IF
0 ['] dark !
_drawmenubar
CLR.L -(A7)
_frontwindow
grayrgn @
MOVE.L (A6)+,-(A7)
_paintbehind
_showcursor
THEN
THEN
['] SavedJGNEFilter @
MOVE.L (A6)+,A0
restore.regs
JMP (A0)
;
( *** definitions for VBLtask that does the blanking *** )
: blankout
call hidecursor
screenbase @ 21888 +
screenbase @
BEGIN
minusone over !
4 + 2dup <
UNTIL 2drop
1 ['] dark !
;
: one.run
save.regs
setup.VBL.stack
ticks @ ['] last.action @ - ['] max.ticks @ >
['] dark @ 0=
AND
IF blankout THEN
60 ['] VBLqelem vblCount + w! ( reschedule )
restore.regs
;
header END
( *** installation of CRT blanker task 'one.run' into VBL queue *** )
variable blockoffset
: get.sys.block
['] end ['] start -
MOVE.L (A6)+,D0
_newptr,sys ( get memory block in system heap )
MOVE.L A0,-(A6)
;
: install.blanker { | pointer offset -- }
get.sys.block -> pointer
pointer IF
0 ['] dark !
ticks @ ['] last.action !
pointer ['] start - -> offset
offset blockoffset !
['] start pointer ['] end ['] start - cmove
( now make all the moves on the relocated block )
['] VBLqelem offset +
dup qtype + vtype swap w!
dup vblAddr + ['] one.run offset + swap !
dup vblCount + 60 swap w!
dup vblPhase + 5 swap w!
call Vinstall drop
ELSE ." Not enough system heap for installation." cr
THEN
;
: install.GNEfilter
JGNEFilter @ ['] SavedJGNEFilter blockoffset @ + !
['] GNEIntfc blockoffset @ + JGNEFilter !
;
: remove.blanker
['] VBLqelem blockoffset @ + call Vremove drop
;
: remove.GNEfilter
['] SavedJGNEFilter blockoffset @ + JGNEFilter !
;
( *** alert boxes to make the thing a little more Mac-like *** )
new.window startalert
50 100 330 400 startalert bounds
alert invisible noclosebox nogrowbox startalert items
700 800 terminal starter
new.control install
" Install" install title
250 50 270 100 install bounds
pushbutton visible 1 0 install items
new.control cancel
" Cancel" cancel title
250 200 270 250 cancel bounds
pushbutton visible 1 0 cancel items
new.window installedalert
50 100 200 400 installedalert bounds
alert invisible noclosebox nogrowbox installedalert items
700 800 terminal installed
new.control ok
" OK" ok title
110 120 130 170 ok bounds
pushbutton visible 1 0 ok items
: finish.control.handler 2drop bye ;
: setup.finish.controls ['] finish.control.handler control-vector ! ;
: go.finish
activate
installedalert call showwindow
installedalert call selectwindow
setup.finish.controls
cr cr
." CRT saver successfully installed." cr
begin pause again
;
: do.install
install.blanker
install.GNEfilter
startalert call hidewindow
installed go.finish
;
: do.cancel bye ;
: start.control.handler
CASE
install @ of do.install endof
cancel @ of do.cancel endof
2drop
endcase
;
: setup.start.controls ['] start.control.handler control-vector ! ;
: go.starter
activate
startalert call showwindow
startalert call selectwindow
setup.start.controls
." CRT saver installation program" cr
." © 1986 by J. Langowski / MacTutor" cr cr
." This program installs a vertical blanking task" cr
." that will automatically darken the screen of" cr
." your Macintosh when no activity (mouseclicks," cr
." keystrokes) are detected for one minute. As" cr
." soon as you press a key or click the mouse, your" cr
." screen will be restored. " cr
." This program in its entirety was written in the" cr
." Forth-83 multitasking Mach1 system. Mach1 is di-" cr
." stributed by: Palo Alto Shipping, P.O.Box 7430," cr
." Menlo Park, CA 94029, phone (800) 44-FORTH." cr
." The CRT saver patches the GetNextEvent routine," cr
." which is inherently dangerous to do. So far, the" cr
." program has been benign in all cases tested." cr
." However, the author can take no responsibility" cr
." for any malfunctions of this little gem nor for" cr
." any consequences such as crashed disks." cr cr
." If you still want to install, click Install."
begin pause again
;
: init-structures
startalert add
startalert starter build
startalert install add
startalert cancel add
installedalert add
installedalert installed build
installedalert ok add
;
: CRTsaver
init-structures
starter go.starter
;